Skip to content

Add PEP 723 inline script metadata to compare.py - #2385

Open
nkltz wants to merge 1 commit into
google:mainfrom
nkltz:main
Open

nkltz wants to merge 1 commit into
google:mainfrom
nkltz:main

Conversation

@nkltz

@nkltz nkltz commented Nov 14, 2026

Copy link
Copy Markdown

compare.py currently does not have an installation method outside of BAZEL, only a requirements.txt at the folder level; its shebang uses python3 in the env, which assumes a python3 interpreter is set up with dependencies installed.

Add inline script metadata to enable running the script with uv.

In conda (pixi), this enables running:

uv run $CONDA_PREFIX/share/googlebenchmark/tools/compare.py

instead of:

uv run --with-requirements $CONDA_PREFIX/share/googlebenchmark/tools/requirements.txt $CONDA_PREFIX/share/googlebenchmark/tools/compare.py

@google-cla

google-cla Bot commented Nov 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@nkltz

nkltz commented Nov 14, 2026

Copy link
Copy Markdown
Author

I signed the CLA, does it match on email address?

@LebedevRI

Copy link
Copy Markdown
Collaborator

We'll now have two places where dependencies will be specified, which means they will go out of sync.
Is there some standard practice for this?

@nkltz

nkltz commented Nov 14, 2026

Copy link
Copy Markdown
Author

We'll now have two places where dependencies will be specified, which means they will go out of sync. Is there some standard practice for this?

Yes there is, that would be a full-on python package with pyproject.toml and dropping the requirements.txt; I can do that instead if you'd rather.
As a side note they are already repeated between the requirements.txt and the BUILD.bazel

@LebedevRI

Copy link
Copy Markdown
Collaborator

We'll now have two places where dependencies will be specified, which means they will go out of sync. Is there some standard practice for this?

Yes there is, that would be a full-on python package with pyproject.toml and dropping the requirements.txt; I can do that instead if you'd rather. As a side note they are already repeated between the requirements.txt and the BUILD.bazel

I'm not going to speak for everybody, but i think the most important mode of operations for that script is just that,
a script that can simply be run from the repo. Does that still just work with the project approach?
Maybe deps duplication is fine...

@nkltz

nkltz commented Nov 15, 2026

Copy link
Copy Markdown
Author

Yes, the script would still be invocable directly in this approach;
I noted that the docs suggest installing the requirements with pip, and the bazel file at that level consumes the requirements.txt as a lockfile and exposes a compare command; If bazel has pyproject.toml support I can refactor both and make the comparecommand available as an entry point even with the pip installation.

Also I can't see whether the tests in the tools are run in the CI; they might only be running for the bindings?

@nkltz
nkltz marked this pull request as draft November 15, 2026 13:06
@LebedevRI

Copy link
Copy Markdown
Collaborator

Personally, i only ever used the script as a directly invocable script, and never ever installed it, etc.
So i'm not sure i'm best to answer that. I guess i personally don't see the point in all the extra complications.

@dmah42

dmah42 commented Nov 16, 2026

Copy link
Copy Markdown
Member

i really don't see the point in this. this script is a utility, not a python "project".

@nkltz

nkltz commented Nov 16, 2026

Copy link
Copy Markdown
Author

Ok, back to the original suggestion: we can make the script installation and invocation easier with inline metadata, it becomes more direct to run with uv (no assumption of python in $PATH with numpy,scipy installed)

@nkltz
nkltz marked this pull request as ready for review November 16, 2026 16:20
@LebedevRI

Copy link
Copy Markdown
Collaborator

I would think this is sufficiently self-contained to be okay.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants